using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 根据任务不同状态，改变玩家与 NPC 交谈的内容
/// </summary>
[RequireComponent(typeof(DialogueController))]
public class QuestGiver : MonoBehaviour
{
    private DialogueController controller;
    QuestData_SO questData;

    // 接受任务
    public DialogueData_SO startDialogue;
    // 任务进行中
    public DialogueData_SO progressDialogue;
    // 任务完成
    public DialogueData_SO completeDialogue;
    // 任务交付结束
    public DialogueData_SO finishDialogue;

    public QuestState GetTaskState()
    {
        if (QuestManager.Instance.HaveTask(questData))
        {
            return QuestManager.Instance.GetQuestTask(questData).TaskState;
        }
        // Debug.LogError("找不到任务状态");
        return QuestState.Start;
    }


    private void Awake()
    {
        controller = GetComponent<DialogueController>();
        // 设置初始对话
        controller.dialogueData = startDialogue;
        // 拿到初始对话的任务数据
        questData = controller.dialogueData.GetQuest();
    }

    private void Update()
    {
        switch (GetTaskState())
        {
            case QuestState.Start:
                break;
            case QuestState.Progress:
                controller.dialogueData = progressDialogue;
                break;
            case QuestState.Complete:
                controller.dialogueData = completeDialogue;
                break;
            case QuestState.Finish:
                controller.dialogueData = finishDialogue;
                break;
        }
    }
}
